// 管理时间的处理

export const Time = (date: Date) => {
  const Dates = new Date(date);
  let y = Dates.getFullYear();
  let m = Dates.getMonth() + 1;
  let ms = "";
  m < 10 ? (ms = "0" + m) : (ms = m.toString());
  let d = Dates.getDate();
  let ds = "";
  d < 10 ? (ds = "0" + d) : (ds = d.toString());
  let h = Dates.getHours();
  let hs = "";
  h < 10 ? (hs = "0" + h) : (hs = h.toString());
  let M = Dates.getMinutes();
  let Ms = "";
  M < 10 ? (Ms = "0" + M) : (Ms = M.toString());
  let s = Dates.getSeconds();
  let ss = "";
  s < 10 ? (ss = "0" + s) : (ss = s.toString());
  return `${y}-${ms}-${ds} ${hs}:${Ms}:${ss}`;
};

export const YearMonth = (date: Date) => {
  const Dates = new Date(date);
  let y = Dates.getFullYear();
  let m = Dates.getMonth() + 1;
  let ms = "";
  m < 10 ? (ms = "0" + m) : (ms = m.toString());
  let d = Dates.getDate();
  let ds = "";
  d < 10 ? (ds = "0" + d) : (ds = d.toString());
  return `${y}-${ms}-${ds}`;
};

export const YearM = (date: Date) => {
  const Dates = new Date(date);
  let y = Dates.getFullYear();
  let m = Dates.getMonth() + 1;
  let ms = "";
  m < 10 ? (ms = "0" + m) : (ms = m.toString());

  return `${y}-${ms}`;
};
